﻿@model Orion.Models.NewsArticle    
@{
    ViewBag.Title = "EditNewsArticle";
    Layout = "~/Views/Shared/_WorkLayout.cshtml";
}

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/tiny_mce/tiny_mce.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/TinyMCE.js")" type="text/javascript"></script>


<section id="main_content_wrapper">
<h1>Breytinga form</h1>
@if ( Model.ContentType == 1 )
{

    using (Html.BeginForm("EditNewsArticle", "WorkNewsArticle", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
    @Html.ValidationSummary(true)

        <input type="hidden" id="ID" name="ID" value="@Model.ID" />
    <fieldset>
        <legend>Skrifa nýja grein</legend>
        <ol>
            <li>
                @Html.LabelFor(model => model.Title, "Titill")
                @Html.EditorFor(model => model.Title)
                @Html.ValidationMessageFor(model => model.Title)
            </li>  
            <li>
                @Html.LabelFor(model => model.TextBody, "Meginmál")
                @Html.TextAreaFor(model => model.TextBody)
                @Html.ValidationMessageFor(model => model.TextBody)
            </li>
            <li>
                  <img src="@Model.Picture" alt="Mynd af notanda" />
                  <label for="file">Mynd</label>
                  <input type="file" name="file" id="file" />
            </li>
            <li>
                <label for="Category">Flokkur</label>
                <select id="Category" name="Category">
                    @foreach (var n in Orion.Controllers.WorkNewsArticleController.GetAllCategories())
                    {
                        <option value="@n.ID">@n.CategoriesType</option>
                    }
		        </select>
            </li>
            <li>
                <label for="Valid">Sýnileg</label>
		        <select id="Valid" name="Valid">            
                    <option value="true">Já</option>
                    <option value="false">Nei</option>
		        </select>
            </li>

            @Html.HiddenFor(model => model.ContentType)
            @Html.HiddenFor(model => model.Author)
            
            <input type="submit" value="Birta" />
        </ol>
    </fieldset>
    }
}
else
{
    using (Html.BeginForm("EditNewsArticle", "WorkNewsArticle", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
    @Html.ValidationSummary(true)
     <input type="hidden" id="ID" name="ID" value="@Model.ID" />
    <fieldset>
        <legend>Skrifa nýja frétt</legend>
        <ol>
            <li>
                @Html.LabelFor(model => model.Title, "Titill")
                @Html.EditorFor(model => model.Title)
                @Html.ValidationMessageFor(model => model.Title)
            </li>
            <li>
                @Html.LabelFor(model => model.TextBody, "Meginmál")
                @Html.TextAreaFor(model => model.TextBody)
                @Html.ValidationMessageFor(model => model.TextBody)
            </li>
            <li>
                <img src="@Model.Picture" alt="Mynd af notanda" />
                <label for="file">Mynd</label>
                <input type="file" name="file" id="file" />
            </li>
            <li>
                <label for="Valid">Sýnileg</label>
		        <select id="Valid" name="Valid">            
                    <option value="true" >Já</option>
                    <option value="false">Nei</option>
		        </select>
            </li>

            
            @Html.HiddenFor(model => model.ContentType)
            @Html.HiddenFor(model => model.Author)

            <input type="submit" value="Birta" />
        </ol>
    </fieldset>
    }
}
</section>